home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1999 July: Mac OS SDK / Dev.CD Jul 99 SDK1.toast / Development Kits / Mac OS / Interfaces&Libraries / Universal / Interfaces / CIncludes / DeskBus.h < prev    next >
Encoding:
C/C++ Source or Header  |  1998-08-17  |  8.8 KB  |  220 lines  |  [TEXT/MPS ]

  1. /*
  2.      File:        DeskBus.h
  3.  
  4.      Contains:    Apple Desktop Bus (ADB) Interfaces.
  5.  
  6.      Version:    Technology:    System 7.5
  7.                  Release:    Universal Interfaces 3.2
  8.  
  9.      Copyright:    © 1987-1998 by Apple Computer, Inc., all rights reserved
  10.  
  11.      Bugs?:        For bug reports, consult the following page on
  12.                  the World Wide Web:
  13.  
  14.                      http://developer.apple.com/bugreporter/
  15.  
  16. */
  17. #ifndef __DESKBUS__
  18. #define __DESKBUS__
  19.  
  20. #ifndef __MACTYPES__
  21. #include <MacTypes.h>
  22. #endif
  23. #ifndef __MIXEDMODE__
  24. #include <MixedMode.h>
  25. #endif
  26.  
  27.  
  28.  
  29. #if PRAGMA_ONCE
  30. #pragma once
  31. #endif
  32.  
  33. #ifdef __cplusplus
  34. extern "C" {
  35. #endif
  36.  
  37. #if PRAGMA_IMPORT
  38. #pragma import on
  39. #endif
  40.  
  41. #if PRAGMA_STRUCT_ALIGN
  42.     #pragma options align=mac68k
  43. #elif PRAGMA_STRUCT_PACKPUSH
  44.     #pragma pack(push, 2)
  45. #elif PRAGMA_STRUCT_PACK
  46.     #pragma pack(2)
  47. #endif
  48.  
  49. #if TARGET_OS_MAC
  50. typedef SInt8                             ADBAddress;
  51. typedef CALLBACK_API( void , ADBCompletionProcPtr )(Ptr buffer, Ptr refCon, long command);
  52. /*
  53.     WARNING: ADBCompletionProcPtr uses register based parameters under classic 68k
  54.              and cannot be written in a high-level language without 
  55.              the help of mixed mode or assembly glue.
  56. */
  57. typedef CALLBACK_API( void , ADBDeviceDriverProcPtr )(SInt8 devAddress, SInt8 devType);
  58. /*
  59.     WARNING: ADBDeviceDriverProcPtr uses register based parameters under classic 68k
  60.              and cannot be written in a high-level language without 
  61.              the help of mixed mode or assembly glue.
  62. */
  63. /*
  64.     TempADBServiceRoutineUPP is needed because of circular definition of
  65.     ADBServiceRoutineProcPtr and ADBServiceRoutineUpp depending on each other.
  66. */
  67. typedef REGISTER_UPP_TYPE(ADBServiceRoutineProcPtr)             TempADBServiceRoutineUPP;
  68. typedef CALLBACK_API( void , ADBServiceRoutineProcPtr )(Ptr buffer, TempADBServiceRoutineUPP completionProc, Ptr refCon, long command);
  69. /*
  70.     WARNING: ADBServiceRoutineProcPtr uses register based parameters under classic 68k
  71.              and cannot be written in a high-level language without 
  72.              the help of mixed mode or assembly glue.
  73. */
  74. typedef REGISTER_UPP_TYPE(ADBCompletionProcPtr)                 ADBCompletionUPP;
  75. typedef REGISTER_UPP_TYPE(ADBDeviceDriverProcPtr)                 ADBDeviceDriverUPP;
  76. typedef REGISTER_UPP_TYPE(ADBServiceRoutineProcPtr)             ADBServiceRoutineUPP;
  77. typedef CALLBACK_API( void , ADBInitProcPtr )(SInt8 callOrder);
  78. /*
  79.     WARNING: ADBInitProcPtr uses register based parameters under classic 68k
  80.              and cannot be written in a high-level language without 
  81.              the help of mixed mode or assembly glue.
  82. */
  83. typedef REGISTER_UPP_TYPE(ADBInitProcPtr)                         ADBInitUPP;
  84.  
  85. struct ADBDataBlock {
  86.     SInt8                             devType;                    /* original handler ID */
  87.     SInt8                             origADBAddr;                /* original ADB Address */
  88.     ADBServiceRoutineUPP             dbServiceRtPtr;                /* service routine pointer */
  89.     Ptr                             dbDataAreaAddr;                /* this field is passed as the refCon parameter to the service routine */
  90. };
  91. typedef struct ADBDataBlock                ADBDataBlock;
  92.  
  93. typedef ADBDataBlock *                    ADBDBlkPtr;
  94.  
  95. struct ADBSetInfoBlock {
  96.     ADBServiceRoutineUPP             siService;                    /* service routine pointer */
  97.     Ptr                             siDataAreaAddr;                /* this field is passed as the refCon parameter to the service routine */
  98. };
  99. typedef struct ADBSetInfoBlock            ADBSetInfoBlock;
  100.  
  101. typedef ADBSetInfoBlock *                ADBSInfoPtr;
  102. /* ADBOpBlock is only used when calling ADBOp from 68k assembly code */
  103.  
  104. struct ADBOpBlock {
  105.     Ptr                             dataBuffPtr;                /* buffer: pointer to variable length data buffer */
  106.     ADBServiceRoutineUPP             opServiceRtPtr;                /* completionProc: completion routine pointer */
  107.     Ptr                             opDataAreaPtr;                /* refCon: this field is passed as the refCon parameter to the completion routine */
  108. };
  109. typedef struct ADBOpBlock                ADBOpBlock;
  110.  
  111. typedef ADBOpBlock *                    ADBOpBPtr;
  112. EXTERN_API( void )
  113. ADBReInit                        (void)                                                        ONEWORDINLINE(0xA07B);
  114.  
  115. /*
  116.     ADBOp has a different interface for 68k assembly than for everything else
  117.     for 68k assembly the interface is 
  118.     #pragma parameter __D0 ADBOp(__A0,__D0)
  119.     OSErr ADBOp( ADBOpBlock * pb, short commandNum );
  120. */
  121. /*
  122.     IMPORTANT NOTE:
  123.     "Inside Macintosh: Devices" documents the completion routine for ADBOp will be called with
  124.     four parameters using 68k register based calling conventions, specifically the completion routine
  125.     passed in should be of type ADBServiceRoutineProcPtr. However, when upp types were first added
  126.     to this interface file, the type ADBCompletionUPP was mistakenly used for the second parameter
  127.     to ADBOp. Since applications have shipped using completion routines of type ADBCompletionUPP,
  128.     the mistake cannot be corrected.
  129.     The only difference between ADBServiceRoutineUPP and ADBCompletionUPP is the former takes an extra
  130.     argument which is a pointer to itself, fortunately not needed for PowerPC code.
  131.     For compatibility with existing 68k code, when an ADBOp completion routine is called,
  132.     68k register A1 will point to the completion routine, as documented in Inside Mac.
  133. */
  134. EXTERN_API( OSErr )
  135. ADBOp                            (Ptr                     refCon,
  136.                                  ADBCompletionUPP         compRout,
  137.                                  Ptr                     buffer,
  138.                                  short                     commandNum);
  139.  
  140.                                                                                             #if TARGET_OS_MAC && TARGET_CPU_68K && !TARGET_RT_MAC_CFM
  141.                                                                                             #pragma parameter __D0 CountADBs
  142.                                                                                             #endif
  143. EXTERN_API( short )
  144. CountADBs                        (void)                                                        ONEWORDINLINE(0xA077);
  145.  
  146.                                                                                             #if TARGET_OS_MAC && TARGET_CPU_68K && !TARGET_RT_MAC_CFM
  147.                                                                                             #pragma parameter __D0 GetIndADB(__A0, __D0)
  148.                                                                                             #endif
  149. EXTERN_API( ADBAddress )
  150. GetIndADB                        (ADBDataBlock *            info,
  151.                                  short                     devTableIndex)                        ONEWORDINLINE(0xA078);
  152.  
  153.                                                                                             #if TARGET_OS_MAC && TARGET_CPU_68K && !TARGET_RT_MAC_CFM
  154.                                                                                             #pragma parameter __D0 GetADBInfo(__A0, __D0)
  155.                                                                                             #endif
  156. EXTERN_API( OSErr )
  157. GetADBInfo                        (ADBDataBlock *            info,
  158.                                  ADBAddress             adbAddr)                            ONEWORDINLINE(0xA079);
  159.  
  160.                                                                                             #if TARGET_OS_MAC && TARGET_CPU_68K && !TARGET_RT_MAC_CFM
  161.                                                                                             #pragma parameter __D0 SetADBInfo(__A0, __D0)
  162.                                                                                             #endif
  163. EXTERN_API( OSErr )
  164. SetADBInfo                        (const ADBSetInfoBlock * info,
  165.                                  ADBAddress             adbAddr)                            ONEWORDINLINE(0xA07A);
  166.  
  167. enum { uppADBCompletionProcInfo = 0x007B9802 };                 /* register no_return_value Func(4_bytes:A0, 4_bytes:A2, 4_bytes:D0) */
  168. enum { uppADBDeviceDriverProcInfo = 0x00050802 };                 /* register no_return_value Func(1_byte:D0, 1_byte:D1) */
  169. enum { uppADBServiceRoutineProcInfo = 0x0F779802 };             /* register no_return_value Func(4_bytes:A0, 4_bytes:A1, 4_bytes:A2, 4_bytes:D0) */
  170. enum { uppADBInitProcInfo = 0x00000802 };                         /* register no_return_value Func(1_byte:D0) */
  171. #define NewADBCompletionProc(userRoutine)                         (ADBCompletionUPP)NewRoutineDescriptor((ProcPtr)(userRoutine), uppADBCompletionProcInfo, GetCurrentArchitecture())
  172. #define NewADBDeviceDriverProc(userRoutine)                     (ADBDeviceDriverUPP)NewRoutineDescriptor((ProcPtr)(userRoutine), uppADBDeviceDriverProcInfo, GetCurrentArchitecture())
  173. #define NewADBServiceRoutineProc(userRoutine)                     (ADBServiceRoutineUPP)NewRoutineDescriptor((ProcPtr)(userRoutine), uppADBServiceRoutineProcInfo, GetCurrentArchitecture())
  174. #define NewADBInitProc(userRoutine)                             (ADBInitUPP)NewRoutineDescriptor((ProcPtr)(userRoutine), uppADBInitProcInfo, GetCurrentArchitecture())
  175. #if TARGET_OS_MAC && TARGET_CPU_68K && !TARGET_RT_MAC_CFM
  176.     /* CallADBCompletionProc can't be called from classic 68k without glue code */
  177. #else
  178.     #define CallADBCompletionProc(userRoutine, buffer, refCon, command)  CALL_THREE_PARAMETER_UPP((userRoutine), uppADBCompletionProcInfo, (buffer), (refCon), (command))
  179. #endif
  180. #if TARGET_OS_MAC && TARGET_CPU_68K && !TARGET_RT_MAC_CFM
  181.     #pragma parameter CallADBDeviceDriverProc(__A0, __D0, __D1)
  182.     void CallADBDeviceDriverProc(ADBDeviceDriverUPP routine, SInt8 devAddress, SInt8 devType) = 0x4E90;
  183. #else
  184.     #define CallADBDeviceDriverProc(userRoutine, devAddress, devType)  CALL_TWO_PARAMETER_UPP((userRoutine), uppADBDeviceDriverProcInfo, (devAddress), (devType))
  185. #endif
  186. #if TARGET_OS_MAC && TARGET_CPU_68K && !TARGET_RT_MAC_CFM
  187.     /* CallADBServiceRoutineProc can't be called from classic 68k without glue code */
  188. #else
  189.     #define CallADBServiceRoutineProc(userRoutine, buffer, completionProc, refCon, command)  CALL_FOUR_PARAMETER_UPP((userRoutine), uppADBServiceRoutineProcInfo, (buffer), (completionProc), (refCon), (command))
  190. #endif
  191. #if TARGET_OS_MAC && TARGET_CPU_68K && !TARGET_RT_MAC_CFM
  192.     #pragma parameter CallADBInitProc(__A0, __D0)
  193.     void CallADBInitProc(ADBInitUPP routine, SInt8 callOrder) = 0x4E90;
  194. #else
  195.     #define CallADBInitProc(userRoutine, callOrder)             CALL_ONE_PARAMETER_UPP((userRoutine), uppADBInitProcInfo, (callOrder))
  196. #endif
  197. #endif  /* TARGET_OS_MAC */
  198.  
  199.  
  200. #if PRAGMA_STRUCT_ALIGN
  201.     #pragma options align=reset
  202. #elif PRAGMA_STRUCT_PACKPUSH
  203.     #pragma pack(pop)
  204. #elif PRAGMA_STRUCT_PACK
  205.     #pragma pack()
  206. #endif
  207.  
  208. #ifdef PRAGMA_IMPORT_OFF
  209. #pragma import off
  210. #elif PRAGMA_IMPORT
  211. #pragma import reset
  212. #endif
  213.  
  214. #ifdef __cplusplus
  215. }
  216. #endif
  217.  
  218. #endif /* __DESKBUS__ */
  219.  
  220.